package com.dsc.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author: Du Shun Chang
 * @title: HelloServlet
 * @date: 2022/2/3 17:20
 * @description: 我的第一个servlet类
 * @version：1.0 继承主类HttpServlet
 *
 */
public class HelloServlet extends HttpServlet {
    /**
     * @author:Du Shun Chang
     * @date:2022/2/3 17:42
     * @title:doGet
     * @param:[req, resp]
     * @return: void
     * @throws:
     * @description: 重写doGet方法
     */
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        /*输出响应*/
        System.out.println("我进入到doGet方法中");
        resp.setContentType("text/html");
        resp.setCharacterEncoding("utf-8");
        PrintWriter writer = resp.getWriter();
        writer.print("<h1>小Du猿您欢迎来到JavaWeb之什么是Servlet<h1>");
    }


    /**
     * @author:Du Shun Chang
     * @date:2022/2/3 17:42
     * @title:doPost
     * @param:[req, resp]
     * @return: void
     * @throws:
     * @description: 重写doPost方法
     */
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
